package com.flame.core.exception;

public class FlameException extends Exception {

    private final String code;

    private final ExceptionLevel level;

    private final Object[] args;

    public FlameException(final ExceptionMessage message) {
        super(message.getMessage());
        this.code = message.getCode();
        this.level = message.getLevel();
        this.args = null;
    }

    public FlameException(ExceptionMessage message, Throwable t) {
        super(message.getMessage(), t);
        this.code = message.getCode();
        this.level = message.getLevel();
        this.args = null;
    }

    public FlameException(ExceptionMessage message, Object... args) {
        super(message.getMessage(args));
        this.code = message.getCode();
        this.level = message.getLevel();
        this.args = (args == null ? null : args.clone());
    }

    public FlameException(ExceptionMessage message, Throwable t, Object... args) {
        super(message.getMessage(args), t);
        this.code = message.getCode();
        this.level = message.getLevel();
        this.args = (args == null ? null : args.clone());
    }

    public String getCode() {
        return code;
    }

    public ExceptionLevel getLevel() {
        return level;
    }

    public Object[] getArgs() {
        return args == null ? null : args.clone();
    }
}
